
require('./common');


exports.load = function(req, res){	
	
	var id = req.params.id;
	var tblname = req.params.tblname;
	
	if(id=="0"){
		var strSQL = "SELECT form.*, ws.ID as WS_ID, ws.FormName FROM " + tblname + ' as form, tblworkspace as ws WHERE ws.Name = '+ conn.escape(tblname) + ' ORDER BY form.ID DESC LIMIT 10 ';
	}else{
		var strSQL = "SELECT form.*, ws.ID as WS_ID, ws.FormName FROM " + tblname + ' as form, tblworkspace as ws WHERE form.ID=' +  conn.escape(id) + ' AND ws.Name = '+ conn.escape(tblname) + ' ORDER BY form.ID DESC LIMIT 10 ';
	}

	conn.query(strSQL, function(err, results, fields){
		if(err) throw err;
			res.send(results);
	});

}

